package com.ct.boot.launch.utils;

import com.google.common.collect.Lists;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @Auther: Charles chen
 * @Date: 2020/7/17 17:28
 * @Description:
 */
public class DozerUtils {
    static Mapper mapper= DozerBeanMapperBuilder.buildDefault();

    public static <T> List<T> mapList(Collection sourceList,Class<?> destinationClass) {
        List destinationList = Lists.newArrayList();
        for(Iterator i$=sourceList.iterator();i$.hasNext();){
            Object sourceObject=i$.next();
            Object destinationObject=mapper.map(sourceObject,destinationClass);
            destinationList.add(destinationObject);
        }
        return destinationList;
    }
}
